<?php

class EnterpriseUserAdmin extends EnterpriseUser
{

    function __construct()
    {
        $this->administrator = true;
    }

    function doPOST( Event $e )
    {
        if ( $e->tag == 'downgrade' ) {
            $this->rebajar();
        }
        parent::doPOST( $e );
    }

    function rebajar()
    {
        Security::removeResourceEdges( array( 'R_USR' => array( $this->id ) ),
                'R_ADM_ENT', $_SESSION[ 'enterprise' ] );
        Security::addResourceEdges( array( 'R_USR' => array( $this->id ) ),
                'R_USR_ENT', $_SESSION[ 'enterprise' ] );

        Security::removeUserRoles( $this->id,
                array( 'ADM_ENT' => array( $_SESSION[ 'enterprise' ] ) ) );
        Security::addUserRoles( $this->id,
                array( 'USR_ENT' => array( $_SESSION[ 'enterprise' ] ) ) );
    }

}

?>
